package com.example.todolist.controller;

import com.example.todolist.entity.PlanTask;
import com.example.todolist.mapper.PlanTaskMapper;
import com.example.todolist.service.PlanTaskService;
import com.example.todolist.tools.ResponseBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/planTask")
public class PlanTaskController {
    @Autowired
    private PlanTaskMapper planTaskMapper;
    @Autowired
    private PlanTaskService planTaskService;
    @GetMapping("/getAllPlanTask")
    public ResponseBody<List<PlanTask>> getAllPlanTask(@RequestParam Integer userId)
    {
        return new ResponseBody<>(200,"success",planTaskMapper.getAllPlanTask(userId));
    }
    @PostMapping("/insertPlanTask")
    public ResponseBody<Integer> insertPlanTask(@RequestParam Integer userId,@RequestBody PlanTask planTask)
    {
        return new ResponseBody<>(200,"success",planTaskMapper.insertPlanTask(planTask));
    }
    @PostMapping("/checkForPlanTask")
    public ResponseBody<Integer> checkForPlanTask(@RequestParam Integer userId,@RequestParam Integer planTaskId)
    {
        return new ResponseBody<>(200,"success",planTaskService.checkForPlanTask(userId,planTaskId));
    }

    @DeleteMapping("/deletePlanTask")
    public ResponseBody<Integer> deletePlanTask(@RequestParam Integer userId,@RequestParam Integer planTaskId)
    {
        return new ResponseBody<>(200,"success",planTaskMapper.deletePlanTask(userId,planTaskId));
    }
}
